package com.iplatform.auth.controller;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import com.iplatform.auth.util.PrivilageConstants;

import springfox.documentation.annotations.ApiIgnore;

@Controller
@RequestMapping("/")
@ApiIgnore
public class IndexController implements PrivilageConstants {
	

	@RequestMapping("")
    public String login2(Map<String, Object> map, String loginMessage) {
        return "login";
    }
	
	/**
	 * 登陆
	 * 
	 * @param map
	 * @param loginMessage
	 * @return
	 */
	@RequestMapping("login")
	public String login(Map<String, Object> map, String loginMessage) {
		return "login";
	}

	@RequestMapping("outIndex")
	public String outIndex(Map<String, Object> map, HttpServletRequest request,
			@RequestParam Map<String, String> formMap) {
		HttpSession session = request.getSession();
		return "forward:" + (String) session.getAttribute(HOME_URL);
	}
	
	@RequestMapping("index")
	public ModelAndView index(Map<String, Object> map, HttpServletRequest request,
			@RequestParam Map<String, String> formMap) {
		ModelAndView mv = new ModelAndView("index");
		mv.addObject("formMap", formMap);

		return mv;
	}
	
	@RequestMapping("home")
	public ModelAndView home(Map<String, Object> map) {
		ModelAndView mv = new ModelAndView("index");
		return mv;
	}
	
}
